package com.taylor.spring5.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @author taylor
 * @Description: TODO
 * @date 2021/4/1 22:59
 */
@Repository
public class UserDaoImpl implements UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Override
    public void add() {
        System.out.println(" userdao add.................");
    }

    @Override
    public int  add(int a,int b) {
        System.out.println(" a+b =？.................");
        return a+b;
    }

    @Override
    public int addAccount() {
        String sql = "update t_account set money=money+? where id=?";
        return jdbcTemplate.update(sql,100,"1");
    }

    @Override
    public int reduceAccount() {
        String sql =  "update t_account set money=money-? where id=?";
        return jdbcTemplate.update(sql,100,"2");
    }
}
